/***********************************************************************
filename: 	EP3DRect.h
created:	10/2/2009
author:		Hongjiang Zhang
Email:		chrisntywyat@163.com

purpose:	
*************************************************************************/
#ifndef EP3D_RECT_H
#define EP3D_RECT_H
#include "EP3DBase.h"
#include "EP3DVector2.h"
#include "EP3DSize.h"

namespace EP3D
{
	class EP3DEXPORT Rect
	{
	public:
		Rect(void);
		Rect(
			f32 l,
			f32 t,
			f32 r,
			f32 b);
		Rect(const Rect& other);
		Rect(Point point, Size size);
		Rect(Point topLeft, Point bottomRight);

		Point BottomRight() const;

		Point CenterPoint() const;
		void CopyRect(const Rect& rect);

		void DeflateRect(f32 x, f32 y);
		void DeflateRect(Size size);
		void DeflateRect(const Rect& rect);
		void DeflateRect(
			f32 l,
			f32 t,
			f32 r,
			f32 b);

		f32 Height() const;
		
		void InflateRect(f32 x, f32 y);
		void InflateRect(Size size);
		void InflateRect(const Rect& rect);
		void InflateRect(
			f32 l,
			f32 t,
			f32 r,
			f32 b);

		bool IntersectRect(const Rect& rect1, const Rect& rect2);

		bool IsRectEmpty() const;

		bool IsRectNull() const;

		void MoveToX(f32 x);
		void MoveToXY(f32 x, f32 y);
		void MoveToXY(Point point);
		void MoveToY(f32 y);

		void NormalizeRect();
		void OffsetRect(f32 x, f32 y);
		void OffsetRect(Point point);
		void OffsetRect(Size size);

		bool PtInRect(Point point) const;

		void SetRect(
			f32 l,
			f32 t,
			f32 r,
			f32 b);

		void SetRect(Point point, Size size);

		void SetRectEmpty();

		Size GetSize() const;
		
		Point TopLeft() const;	

		bool UnionRect(const Rect& rect1, const Rect& rect2);

		f32 Width() const;

		Rect operator + (Point point) const;
		Rect operator - (Point point) const;

		Rect& operator += (Point point);
		Rect& operator -= (Point point);

		Rect operator * (f32 scale) const;
		const Rect& operator *= (f32 scale);

		bool operator != (const Rect& rect) const;
		bool operator == (const Rect& rect) const;

		//data member
		f32 left;
		f32 top;
		f32 right;
		f32 bottom;
	};
}


#endif